#!/usr/bin/python3
# -*- coding:utf-8 -*-
# __author__ == taoyulong2018@gmail.com
# __time__ == 2023/8/23 8:42
# ===========================================
#       题目名称： 26. 删除有序数组中的重复项
#       题目地址： https://leetcode.cn/problems/remove-duplicates-from-sorted-array/description/
#       题目描述： https://note.youdao.com/s/RRXNSXjR
# ===========================================


class Solution:
    """
        实现思路：
           直接del
    """

    def removeDuplicates(self, nums):
        cur_index = 0
        while cur_index + 1 < len(nums):
            if nums[cur_index] == nums[cur_index + 1]:
                del nums[cur_index]
            else:
                cur_index += 1
        return len(nums)


if __name__ == '__main__':
    s = Solution()
    # 2
    print(s.removeDuplicates(nums=[1, 1, 2]))
    # 5
    print(s.removeDuplicates(nums=[0, 0, 1, 1, 1, 2, 2, 3, 3, 4]))
